package org.domain.seam1.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.*;

import org.jboss.seam.annotations.security.management.RoleConditional;
import org.jboss.seam.annotations.security.management.RoleGroups;
import org.jboss.seam.annotations.security.management.RoleName;

/**
 * Entity implementation class for Entity: Role
 * 
 */
@Entity
public class Role implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 544605516498416636L;
	private Integer roleId;
	private String rolename;
	private boolean conditional;
	private Set<Role> groups;
	
	public Role(){}
	
	public Role(String rolename) {
		this();
		this.rolename = rolename;
	}

	@Id
	@GeneratedValue
	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	@RoleName
	@Column(unique = true)
	public String getRolename() {
		return rolename;
	}

	public void setRolename(String rolename) {
		this.rolename = rolename;
	}

	@RoleConditional
	public boolean isConditional() {
		return conditional;
	}

	public void setConditional(boolean conditional) {
		this.conditional = conditional;
	}

	@RoleGroups
	@ManyToMany(targetEntity = Role.class)
	@JoinTable(name = "RoleGroups", joinColumns = @JoinColumn(name = "RoleId"), inverseJoinColumns = @JoinColumn(name = "GroupId"))
	public Set<Role> getGroups() {
		return groups;
	}

	public void setGroups(Set<Role> groups) {
		this.groups = groups;
	}
}